﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpDemo._03_继承
{
    class Animal
    {
        private string Name;

        public Animal()
        {
            Name = "动物";
        }

        public Animal(string Name)
        {
            this.Name = Name;
        }


        public string getName()
        {
            return this.Name;
        }
    }

    class Dog : Animal
    {
        //默认调用父类无参数的构造函数
        public Dog()
        {

        }

        //调用父类带参数的构造函数 
        public Dog(string Name)
            : base(Name)
        { 
        
        }
    }

    class InheritanceTest
    {
        public static void Test()
        {
            Dog a = new Dog();
            Console.WriteLine(a.getName());

            Dog b = new Dog("小狗");
            Console.WriteLine(b.getName());
        }
    }
}
